Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #12143 support streaming mode content start with "data:" #12171

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

jifei
Copy link
Contributor

@jifei jifei commented Dec 27, 2024

Summary

When deploying LLM with ms-swift, the streaming data returned does not consistently start with "data: ". Specifically, the data does not include a leading space after "data:". This inconsistency stems from the pull request #11272 return failed,the version of Dify before 0.13.0 is ok. To address this, my code has been updated to support both formats: "data:" and "data: "

streaming content e.g.

"data:{"model": "my-llm", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "Hello! How ", "tool_calls": null}, "finish_reason": null, "logprobs": null}], "usage": {"prompt_tokens": 30, "completion_tokens": 7, "total_tokens": 37}, "id": "chatcmpl-d802c95d766a41a5bf9491aafdba2b36", "object": "chat.completion.chunk", "created": 1735303124}"

Fixes #12143

Screenshots

Before
image

After
image

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. ⚙️ feat:model-runtime labels Dec 27, 2024
@jifei jifei marked this pull request as draft December 27, 2024 15:18
@jifei jifei changed the title support steaming mode content start with data: fix bug:support steaming mode content start with data: Dec 27, 2024
@jifei jifei marked this pull request as ready for review December 27, 2024 15:27
@dosubot dosubot bot added the 🐞 bug Something isn't working label Dec 27, 2024
@jifei jifei changed the title fix bug:support steaming mode content start with data: fix bug:support streaming mode content start with data: Dec 27, 2024
@jifei jifei changed the title fix bug:support streaming mode content start with data: fix bug:support streaming mode content start with data: Dec 27, 2024
@jifei jifei changed the title fix bug:support streaming mode content start with data: fix bug:support streaming mode content start with "data:" Dec 27, 2024
@yihong0618
Copy link
Contributor

cool~ seems better add some comments to link the issue?

@jifei
Copy link
Contributor Author

jifei commented Dec 31, 2024

cool~ seems better add some comments to link the issue?

Arose during the deployment of the Qwen2.5 model experiment with vllm version 0.5.1 and ms-swift version 2.4.2.post1, specifically when using the stream mode. The returned content is as follows:
data:{"model": "my-llm", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "Hello! How ", "tool_calls": null}, "finish_reason": null, "logprobs": null}], "usage": {"prompt_tokens": 30, "completion_tokens": 7, "total_tokens": 37}, "id": "chatcmpl-d802c95d766a41a5bf9491aafdba2b36", "object": "chat.completion.chunk", "created": 1735303124}

Specifically, the data does not include a leading space after "data:". The issue stems from the outdated versions of vllm or ms-swift, but the direct cause of the incompatibility and failure is due to pull request #11272 by dify.

@jifei jifei changed the title fix bug:support streaming mode content start with "data:" fix: #12143 support streaming mode content start with "data:" Dec 31, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 3, 2025
@crazywoola crazywoola merged commit 3c2e30f into langgenius:main Jan 3, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working ⚙️ feat:model-runtime lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAI-API-compatible model not support streaming mode
3 participants